using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpTableReference : OracleLpStatementDataContainer
	{
		protected OracleLpQueryTableExpression m_vQueryTableExpression;

		protected bool m_vOnlyQTE;

		protected OracleLpTableReferenceType m_vTableReferenceType;

		protected OracleLpName m_vAlias;

		protected bool m_vInNullableJoin;

		internal override OracleLpStatementElementType ElementType => OracleLpStatementElementType.TableReference;

		public OracleLpQueryTableExpression QueryTableExpression
		{
			get
			{
				return m_vQueryTableExpression;
			}
			set
			{
				m_vQueryTableExpression = value;
				if (m_vQueryTableExpression != null)
				{
					m_vQueryTableExpression.Parent = this;
				}
			}
		}

		public bool OnlyQTE
		{
			get
			{
				return m_vOnlyQTE;
			}
			set
			{
				m_vOnlyQTE = value;
			}
		}

		public OracleLpTableReferenceType TableReferenceType
		{
			get
			{
				return m_vTableReferenceType;
			}
			internal set
			{
				m_vTableReferenceType = value;
			}
		}

		public OracleLpName Alias
		{
			get
			{
				return m_vAlias;
			}
			internal set
			{
				m_vAlias = value;
			}
		}

		public bool InNullableJoin
		{
			get
			{
				return m_vInNullableJoin;
			}
			set
			{
				m_vInNullableJoin = value;
			}
		}

		public override List<OracleLpColumnDescriptor> ColumnDescriptors
		{
			get
			{
				if (m_vQueryTableExpression != null)
				{
					return m_vQueryTableExpression.ColumnDescriptors;
				}
				return null;
			}
		}

		public OracleLpTableReference(OracleLpStatementElement se)
			: base(se)
		{
		}

		public override void RetrieveNamedObjectReferences(OracleLpStatement statement)
		{
			if (m_vQueryTableExpression != null)
			{
				m_vQueryTableExpression.RetrieveNamedObjectReferences(statement);
			}
		}

		internal override void ToString(StringBuilder sb)
		{
			string depthIndent = base.DepthIndent;
			sb.Append(depthIndent);
			sb.Append("Type:  ");
			sb.Append(m_vTableReferenceType);
			sb.Append("  Alias: ");
			sb.Append((m_vAlias == null) ? "none" : (m_vAlias.DbName ?? "none"));
			if (m_vQueryTableExpression != null)
			{
				m_vQueryTableExpression.ToString(sb);
			}
		}
	}
}
